﻿
Imports MySql.Data.MySqlClient

Public Class Form5
    Dim con As MySqlConnection
    Dim cmd As MySqlCommand
    Dim da As MySqlDataAdapter
    Dim dr As MySqlDataReader
    Dim result As Integer
    Dim query As String

    Private Sub btnCancel_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnCancel.Click
        Me.Close()
    End Sub

    Private Sub btnAdd_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnAdd.Click
        Dim con As New MySqlConnection
        con.ConnectionString = "server=localhost;userid=root;password= ;database=librarysys"
        Dim dr As MySqlDataReader

        Try
            con.Open()
            Dim query As String
            query = "INSERT INTO librarysys.tblbookinv (bookid,title,author,publisher,copyright,isbn,datein,note,by) VALUES ('" & txtBookId.Text & "','" & txtTitle.Text & "','" & txtAuthor.Text & "','" & txtPublisher.Text & "','" & txtCopyright.Text & "','" & txtISBN.Text & "','" & dtpDateIn.Text & "','" & txtNote.Text & "','" & txtBy.Text & "')"

            cmd = New MySqlCommand(query, con)
            dr = cmd.ExecuteReader

            MessageBox.Show("Data successfully saved!")
            con.Close()
        Catch ex As Exception
            MessageBox.Show(ex.Message)
        Finally
            con.Dispose()
        End Try
    End Sub

    Private Function conn() As Object
        Throw New NotImplementedException
    End Function

End Class